package com.g4.shoppingsingle.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.g4.shoppingsingle.common.Result;
import com.g4.shoppingsingle.dto.CartInfoDTO;
import com.g4.shoppingsingle.pojo.DdCartDetail;
import com.g4.shoppingsingle.pojo.DdCategorysInfo;
import com.g4.shoppingsingle.service.IDdCartDetailService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 购物车表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-10-27
 */
@RestController
@RequestMapping("/shoppingsingle/ddCartDetail")
public class DdCartDetailController {

    @Autowired
    IDdCartDetailService iDdCartDetailService;

    /**
     * 当前登录用户的购物车商品信息
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询购物车商品信息")
    public Result list(){
        List<CartInfoDTO>  list = iDdCartDetailService.selectList();
        return Result.ok(list);
    }

    /**
     * 添加购物车
     * @return
     */
    @PostMapping("/addCart/{typeId}/{productId}")
    public Result addCart(@PathVariable Integer typeId,
                          @PathVariable Integer productId){
        iDdCartDetailService.addCart(typeId,productId);
        return Result.ok();
    }

}
